//
//  ZZGestureLockViewController.m
//  基本框架
//
//  Created by runone02 on 2018/8/16.
//  Copyright © 2018年 liqiyun. All rights reserved.
//

#import "ZZGestureLockViewController.h"
#import "ZZGestureLockView.h"

@interface ZZGestureLockViewController ()<ZZGestureLockViewDelegate>

/** */
@property (nonatomic, strong) ZZGestureLockView *lockView;
/** */
@property (nonatomic, strong) UILabel *resultLabel;

@end

@implementation ZZGestureLockViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadLockView];
}

- (void)loadLockView{
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.lockView = [[ZZGestureLockView alloc]init];
    [self.view addSubview:self.lockView];
    [self.lockView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(kTopBarHeight+20);
        make.left.mas_equalTo(self.view).with.offset(20);
        make.right.mas_equalTo(self.view).with.offset(-20);
        make.bottom.mas_equalTo(self.view).with.offset(-50);
    }];
    
    self.lockView.itemWidth = 60;
    self.lockView.miniPasswordLength = 4;
    self.lockView.normalLineColor = RGBA(252, 222, 117, 1);
    self.lockView.warningLineColor = RGBA(249, 78, 92, 1);
    self.lockView.delegate = self;
    
    self.resultLabel = [[UILabel alloc]init];
    self.resultLabel.font = TITLE_FONT(30);
    self.resultLabel.textAlignment = NSTextAlignmentCenter;
    self.resultLabel.text = @"密码:";
    [self.view addSubview:self.resultLabel];
    [self.resultLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.lockView.mas_bottom).with.offset(10);
        make.left.right.bottom.mas_equalTo(self.view);
    }];
}

- (void)zzGestureLockViewDidStarWithLockVIew:(ZZGestureLockView *)lockView{
    NSLog(@"开始连接");
}

- (void)zzGestureLockViewDidEndWithLockView:(ZZGestureLockView *)lockView itemState:(ZZGestureLockItemState)itemState gestureResult:(NSString *)gestureResult{
    NSLog(@"结束连接");
    if (itemState == ZZGestureLockItemStateNormal) {
        self.resultLabel.text = [NSString stringWithFormat:@"密码%@",gestureResult];
    }else{
        self.resultLabel.text = @"请至少连接四个点";
    }
}


@end
